//
//  LbxLoggerServerWindow.m
//  WebServerTools
//
//  Created by 夏利兵 on 2020/9/23.
//  Copyright © 2020 com.lbx. All rights reserved.
//

#import "LbXLoggerServerWindow.h"
#import "LBXLoggerRealServer.h"

@interface LbXLoggerServerWindow ()
@property (weak) IBOutlet NSTextField *urlLabel;

@end

@implementation LbXLoggerServerWindow

- (void)windowDidLoad {
    [super windowDidLoad];
    
    self.urlLabel.stringValue = @"服务器未开启";

    
    // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
}

- (IBAction)start:(id)sender {
    
    if ([[LBXLoggerRealServer sharedManager]start])
    {
        self.urlLabel.stringValue = [[LBXLoggerRealServer sharedManager]visitUrl];
        
        NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
        
        [pasteboard declareTypes:@[NSPasteboardTypeString] owner:nil];
        
        if ([pasteboard setString:self.urlLabel.stringValue forType:NSPasteboardTypeString])
        {
            NSLog(@"success");
        }
    }
}

- (IBAction)stop:(id)sender
{
    [[LBXLoggerRealServer sharedManager]stop];
    self.urlLabel.stringValue = @"服务器未开启";
    
}
- (IBAction)testAddLog:(id)sender {
    
    static NSInteger num = 10000;
    
    NSString *msg = [NSString stringWithFormat:@"servlog:%ld",(long)num++];
    
    [[LBXLoggerRealServer sharedManager]sendMessage:msg];
}

@end
